﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x0200004A RID: 74
	public class NullableByteFormatter : IMessagePackFormatter<byte?>
	{
		// Token: 0x06000117 RID: 279 RVA: 0x00004AD4 File Offset: 0x00002ED4
		private NullableByteFormatter()
		{
		}

		// Token: 0x06000118 RID: 280 RVA: 0x00004ADC File Offset: 0x00002EDC
		public int Serialize(ref byte[] bytes, int offset, byte? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteByte(ref bytes, offset, value.Value);
		}

		// Token: 0x06000119 RID: 281 RVA: 0x00004B04 File Offset: 0x00002F04
		public byte? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new byte?(MessagePackBinary.ReadByte(bytes, offset, out readSize));
		}

		// Token: 0x0400003E RID: 62
		public static readonly NullableByteFormatter Instance = new NullableByteFormatter();
	}
}
